<!DOCTYPE html>
<html ng-app="myApp">
<head>
    <meta charset="utf-8">
    <title>AngularJS&middot; Controller</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.2/css/bootstrap.css">
    <link rel="stylesheet" href="../static/js/prettify/prettify.css"/>
    <style>
        .demo{
            margin-bottom:10px;
            border-bottom:1px solid #1b926c;
        }
    </style>
</head>
<body>
  <div class="container">
      <div class="row">
          <nav class="navbar navbar-default">
              <div class="container-fluid">
                  <div class="navbar-header">
                      <a class="navbar-brand" href="../index.html">首页</a>
                  </div>
                  <ul class="nav navbar-nav">
                      <li class="active"><a href="javascript:void(0)">Link</a></li>
                      <li><a href="javascript:void(0)">Link2</a></li>
                  </ul>
              </div>
          </nav>
      </div>
      <div class="row demo">

<pre>
    var myApp = angular.module('myApp', []); //注意app创建时需要添加第二个参数
    myApp.controller('MainController',function(){
        var vm=this;
        vm.title='AngularJS Controller取别名示例2';
        vm.searchInput='';
    });
</pre>
          <div ng-controller="MainController as main">
              <h3>Demo1-{{main.title}}</h3>
              <div class="input-group">
                  <span class="input-group-addon">
                      <span class="glyphicon glyphicon-search"></span>
                  </span>
                  <input type="text" class="form-control" ng-model="main.searchInput">
              </div>
              <p>输出：<b>{{main.searchInput}}</b></p>
              <p>参考：<b> <a href="http://www.revillweb.com/tutorials/angularjs-in-30-minutes-angularjs-tutorial/" target="_blank">http://www.revillweb.com/tutorials/angularjs-in-30-minutes-angularjs-tutorial/</a> </b></p>
          </div>
      </div>
  </div>
</body>
</html>
<script src="http://cdn.bootcss.com/jquery/2.1.3/jquery.min.js" type="text/javascript"></script>
<script src="http://cdn.bootcss.com/angular.js/1.3.8/angular.js" type="text/javascript"></script>
<script src="../static/js/prettify/prettify.min.js"></script>
<script>
    /**
     * pretiffy美化代码
     */
    $(function() {
        $('pre').addClass('prettyprint linenums').attr('style', 'overflow:auto');
        window.prettyPrint && prettyPrint();
    });
</script>
<script>
    var myApp = angular.module('myApp', []); //注意app创建时需要添加第二个参数
    myApp.controller('MainController',function(){
        var vm=this;
        vm.title='AngularJS Controller取别名示例2';
        vm.searchInput='';
    });
</script>
